//- Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. 
//- <https://www.chatopera.com>, Licensed under the Chunsong Public 
//- License, Version 1.0  (the "License"), https://docs.cskefu.com/licenses/v1.html
//- Unless required by applicable law or agreed to in writing, software
//- distributed under the License is distributed on an "AS IS" BASIS,
//- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//- See the License for the specific language governing permissions and
//- limitations under the License.
//- Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>
//- Licensed under the Apache License, Version 2.0
//- http://www.apache.org/licenses/LICENSE-2.0
include /mixins/dic.mixin.pug

.uk-layui-form
    form.layui-form.uk-form(action='/admin/metadata/update.html')
        input(type='hidden', name='id', value=metadata.id)
        .layui-form-item
            label.layui-form-label 标题：
            .layui-input-inline
                input.layui-input(type='text', name='name', value=metadata.name, required, lay-verify='required', placeholder='标题', autocomplete='off')

        .layui-form-item
            label.layui-form-label 选项：
            .layui-input-inline
                input(type="checkbox", name="fromdb", title="ES数据", lay-skin="primary", lay-filter="es", checked=(metadata.fromdb ? 'checked' : false) )

        .layui-form-item.es(style="display:" + (metadata.fromdb == false ? 'none;' : 'block;'))
            label.layui-form-label ES资源：
            .layui-input-inline
                +sysDicSelect('com.dic.es.type','listblocktemplet',metadata.listblocktemplet,"lay-ignore required lay-verify='required' ")

        .layui-form-item.es(style="display:" + (metadata.fromdb == false ? 'none;' : 'block;'))
            label.layui-form-label JAVABean：
            .layui-input-inline
                +sysDicSelect('com.dic.db.type','previewtemplet',metadata.previewtemplet,"lay-ignore required lay-verify='required' ")

        .layui-form-button
            .layui-button-block
                button.layui-btn(lay-submit, lay-filter='formDemo') 立即提交
                button.layui-btn.layui-btn-original(type='reset') 重置
script.
    layui.use('form', function () {
        var form = layui.form();
        form.render(); //更新全部
        form.on("checkbox(es)", function (data) {
            if (data.elem.checked == true) {
                $('.es').show();
            } else {
                $('.es').hide();
            }
        });
        form.verify({
            repass: function (value) {
                if (value != $('#password').val()) {
                    return '两次输入的密码不一致，请确认';
                }
            }
        });
    });

